﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ValidationException.cs" company="Collaboris Ltd.">
//   Copyright (c) Collaboris Ltd. All rights Reserved.
// </copyright>
// <summary>
//   This Exception will be thrown if an Action (or its Entity)
//   is invalid.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Collaboris.Saf.Exceptions
{
    using System;
    using System.Collections.Generic;
    using System.Runtime.Serialization;

    using Collaboris.Saf.Engine;

    /// <summary>
    /// This Exception will be thrown if an Action (or its Entity)
    /// is invalid.
    /// </summary>
    public class ValidationException : ApplicationException
    {
        #region Fields (1) 

        List<ValidationError> errorList;

        #endregion Fields 

        #region Constructors (4) 

        /// <summary>
        /// Initializes a new instance of the <see cref="ValidationException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="rootCause">The root cause.</param>
        /// <param name="errors">The errors.</param>
        public ValidationException(string message, Exception rootCause, List<ValidationError> errors)
                : base(message, rootCause)
        {
            this.errorList = this.errorList;
        }


        /// <summary>
        /// Initializes a new instance of the <see cref="ValidationException"/> class.
        /// </summary>
        /// <param name="info">The info.</param>
        /// <param name="context">The context.</param>
        /// <param name="errors">The errors.</param>
        protected ValidationException (
                SerializationInfo info, StreamingContext context, List<ValidationError> errors)
                : base (info, context)
        {
            this.errorList = this.errorList;
        }


        /// <summary>
        /// Initializes a new instance of the <see cref="ValidationException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="errors">The errors.</param>
        public ValidationException(string message, List<ValidationError> errors)
                : base(message)
        {
            this.errorList = this.errorList;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ValidationException"/> class.
        /// </summary>
        /// <param name="errors">The errors.</param>
        public ValidationException(List<ValidationError> errors)
        {
            this.errorList = this.errorList;
        }

        #endregion Constructors 

        #region Properties (1) 

        /// <summary>
        /// Gets or sets the error list.
        /// </summary>
        /// <value>The error list.</value>
        public List<ValidationError> ErrorList
        {
            get
            {
                return this.errorList;
            }
            set
            {
                this.errorList = value;
            }
        }

        #endregion Properties 
    }
}